<h1>If</h1>

<p>The If action is used to perform a conditional branch to control the actions executed 
by the Flash Player. When executed, the If action pops a value from the stack and 
evaluates it to see whether it evaluates as true or false. If the boolean value 
is true the offset attribute of the If action is added to the Flash Player's instruction pointer and execution of the stream of actions continues from that location. If the boolean value is false then no branch is taken.</p>

<p>Although the Flash Player contains an instruction pointer it does not support an explicit address space. The instruction pointer is used to reference actions within the current stream of actions being executed whether they are associated with a given frame, button or movie clip. The value contained in the instruction pointer is the address relative to the start of the current stream.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top"><a name="ActionType">Type</a></td>
<td nowrap valign="top">unsigned int</td>
<td nowrap align="right">8</td>
<td>Identifies the action when it is encoded.</td>
</tr>

<tr>
<td nowrap valign="top"><a name="ActionLength">Length</a></td>
<td nowrap valign="top">unsigned int</td>
<td nowrap align="right">16</td>
<td>The number of bytes in the rest of the encoded action. The total number of
bytes in the encoded action is Length+3.</td>
</tr>

<tr>
<td nowrap valign="top">offset</td>
<td nowrap valign="top">signed int</td>
<td nowrap align="right">16</td>
<td>The offset, relative to the current instruction pointer, to jump to if the value on the Stack evaluates to true.</td>
</tr>
</table>

<p>The offset is a signed number, allowing branches up to -32768 to 32767 bytes. 
The instruction pointer points to the next instruction in the stream of actions 
being executed so specifying an offset of zero will have no effect on the sequence 
of instructions executed.</p>

<p>If the value popped off the stack is a number it is evaluated as true if it 
is non-zero. If the value is a string it is evaluated to true if it is not an 
empty string ("") or the strings "0" or "false".</p>

<h2>History</h2>

<p>If represents the ActionIf action of the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 4.</p>
